package com.dahouzi.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dahouzi.commom.Feedback;
import com.dahouzi.dao.entity.TArticle;
import com.dahouzi.service.TArticleService;

@Controller
@PreAuthorize("hasRole('admin')")
@RequestMapping("/Article4AdminCtrl")
public class Article4AdminCtrl {
	@Autowired
	private TArticleService tArticleService;

	@RequestMapping("/summernotEdit")
	public String summernotEdit() {
		TArticle art = new TArticle();
		art.setAuthor("lgl");
		// tArticleService.insert(art);
		return "table/admin/article/summernoteEdit";
	}

	@RequestMapping("/simditorEdit")
	public String simditorEdit() {
		TArticle art = new TArticle();
		art.setAuthor("lgl");
		// tArticleService.insert(art);
		return "table/admin/article/simditorEdit";
	}

	/**
	 *
	 * @author 空空dream
	 * @date 2017年10月3日
	 */
	@RequestMapping(value = "/articlePost", method = RequestMethod.PUT)
	public @ResponseBody Feedback getWaitReceive(TArticle article) {
		article.insert();

		System.out.println(article.getId() + article.getArticle());
		return Feedback.success(Feedback.MSG_SAVE_SUCCESS, article);
	}

}
